package com.zhang.serviceprice.controller;

import com.zhang.internalcommon.dto.ForecastPrceDTO;
import com.zhang.internalcommon.dto.ResponseResult;
import com.zhang.serviceprice.service.PriceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ADMIN
 */
@RestController
@Slf4j
public class ForecastPriceController {

	@Autowired
	PriceService priceService;

	@PostMapping("/forecast-price")
	public ResponseResult forecastPrice(@RequestBody ForecastPrceDTO forecastPrceDTO){
		String depLongitude = forecastPrceDTO.getDepLongitude();
		String depLatitude = forecastPrceDTO.getDepLatitude();
		String destLongitude = forecastPrceDTO.getDestLongitude();
		String destLatitude = forecastPrceDTO.getDestLatitude();
		String cityCode = forecastPrceDTO.getCityCode();
		String vehicleType = forecastPrceDTO.getVehicleType();

		log.info("出发经度" + depLongitude);
		log.info("出发纬度" + depLatitude);
		log.info("目的经度" + destLongitude);
		log.info("目的纬度" + destLatitude);
		return priceService.forecastPrice(depLongitude, depLatitude, destLongitude, destLatitude,cityCode,vehicleType);
	}

	/**
	 * 计算实际价格
	 * @param distance
	 * @param duration
	 * @param cityCode
	 * @param vehicleType
	 * @return
	 */
	@PostMapping("/calculate-price")
	public ResponseResult<Double> calculatePrice(@RequestParam Integer distance , @RequestParam Integer duration, @RequestParam String cityCode, @RequestParam String vehicleType){
		return priceService.calculatePrice(distance,duration,cityCode,vehicleType);
	}
}
